package org.marsdonne.audits;

import com.fasterxml.jackson.databind.JsonNode;

import java.lang.management.ManagementFactory;

public interface NoteAuditable {
    void write(Noted noted);

    default void write(Noted.Level level, JsonNode message) {
        Noted noted = new Noted(level, message);
        noted.setProcessId(ManagementFactory.getRuntimeMXBean().getName());
        this.write(noted);
    }

    default void warn(JsonNode message) {
        this.write(Noted.Level.Warn, message);
    }

    default void info(JsonNode message) {
        this.write(Noted.Level.Info, message);
    }

    default void error(JsonNode message) {
        this.write(Noted.Level.Error, message);
    }
}
